package com.spzx.payment.controller;

import java.util.List;
import java.util.Arrays;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spzx.common.log.annotation.Log;
import com.spzx.common.log.enums.BusinessType;
import com.spzx.common.security.annotation.RequiresPermissions;
import com.spzx.payment.domain.PaymentInfo;
import com.spzx.payment.service.IPaymentInfoService;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.common.core.utils.poi.ExcelUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.spzx.common.core.web.page.TableDataInfo;

/**
 * 付款信息Controller
 *
 * @author atguigu
 * @date 2024-09-02
 */
@Tag(name = "付款信息接口管理")
@RestController
@RequestMapping("/paymentInfo")
public class PaymentInfoController extends BaseController
{
    @Autowired
    private IPaymentInfoService paymentInfoService;

    /**
     * 查询付款信息列表
     */
    @Operation(summary = "查询付款信息列表")
    @RequiresPermissions("payment:paymentInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(PaymentInfo paymentInfo)
    {
        startPage();
        List<PaymentInfo> list = paymentInfoService.selectPaymentInfoList(paymentInfo);
        return getDataTable(list);
    }

    /**
     * 导出付款信息列表
     */
    @Operation(summary = "导出付款信息列表")
    @RequiresPermissions("payment:paymentInfo:export")
    @Log(title = "付款信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaymentInfo paymentInfo)
    {
        List<PaymentInfo> list = paymentInfoService.selectPaymentInfoList(paymentInfo);
        ExcelUtil<PaymentInfo> util = new ExcelUtil<PaymentInfo>(PaymentInfo.class);
        util.exportExcel(response, list, "付款信息数据");
    }

    /**
     * 获取付款信息详细信息
     */
    @Operation(summary = "获取付款信息详细信息")
    @RequiresPermissions("payment:paymentInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paymentInfoService.getById(id));
    }

    /**
     * 新增付款信息
     */
    @Operation(summary = "新增付款信息")
    @RequiresPermissions("payment:paymentInfo:add")
    @Log(title = "付款信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaymentInfo paymentInfo)
    {
        return toAjax(paymentInfoService.save(paymentInfo));
    }

    /**
     * 修改付款信息
     */
    @Operation(summary = "修改付款信息")
    @RequiresPermissions("payment:paymentInfo:edit")
    @Log(title = "付款信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaymentInfo paymentInfo)
    {
        return toAjax(paymentInfoService.updateById(paymentInfo));
    }

    /**
     * 删除付款信息
     */
    @Operation(summary = "删除付款信息")
    @RequiresPermissions("payment:paymentInfo:remove")
    @Log(title = "付款信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paymentInfoService.removeBatchByIds(Arrays.asList(ids)));
    }
}
